home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / dhcp / dhcp-leases.frm.z / dhcp-leases.frm
Encoding:
Text File  |  2002-06-12  |  2.7 KB  |  90 lines

  1. #!/usr/bin/perl5
  2. #
  3. # dhcp-leases.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: dhcp-leases.frm,v 1.18 1997/12/23 21:32:44 jrw Exp $
  21.  
  22. BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
  23. require "/usr/OnRamp/lib/OnRamp.pm";
  24.  
  25. $query = new CGI;
  26.  
  27. $title = "DHCP Leases";
  28.  
  29. print $query->header;
  30. &title_block($title);
  31.  
  32. sub error {
  33.     &error_block($_[0]);
  34.     exit 0;
  35. }
  36.  
  37. $srv_off = system ("/etc/chkconfig", "proclaim_server");
  38. if ($srv_off) {
  39.     &error("This system is not configured to be a DHCP server.");
  40. }
  41.  
  42. if (-e "/usr/sbin/dbmToEthIP") { 
  43.     # Running IRIX 6.5 - create a text file
  44.     system("/usr/sbin/dbmToEthIP > /tmp/etherToIP");
  45.     $lsf = "/tmp/etherToIP";
  46. } else {
  47.     $lsf = "/var/dhcp/etherToIP";
  48. }
  49. open(LEASE, $lsf) || &error("There are no current address leases.");
  50.  
  51. &header_block($title);
  52.  
  53. print "<center><table cellpadding=5 width=450>";
  54. print "<tr><th align=left>Hostname<th align=left>Domain<th align=left>
  55.         IP Address<th align=left>Expiration";
  56. while(<LEASE>) {
  57.     chop;
  58.     ($ether, $ip, $host, $expiry) = split(/\s+/);
  59.     ($hname, @domain) = split(/\./, $host);
  60.     $domain = join('.', @domain);
  61.     if ($expiry) {
  62.     if (time < $expiry) {
  63.         @gt = localtime $expiry;
  64.         $date = sprintf "%02d/%02d/%02d", $gt[4]+1, $gt[3], $gt[5];
  65.         $fol = "AM";
  66.         if ($gt[2] == 12) { $fol = "PM"; }
  67.         if ($gt[2] > 12) { $gt[2] -= 12; $fol = "PM"; }
  68.         if ($gt[1] < 10) { $gt[1] = "0$gt[1]"; }
  69.         $time = "$gt[2]:$gt[1] $fol";
  70.         print "<tr><td align=left>$hname<td align=left>$domain" .
  71.         "<td align=left>$ip<td align=left>$time, $date</tr>\n";
  72.     } else {
  73.         print "<tr><td align=left>$hname<td align=left>$domain" .
  74.         "<td align=left>$ip<td align=left>Expired</tr>\n";
  75.     }
  76.     }
  77.     else {
  78.     print "<tr><td align=left>$hname<td align=left>$domain" .
  79.         "<td align=left>$ip<td align=left>Negotiating</tr>\n";
  80.     }
  81. }
  82. close(LEASE);
  83.  
  84. if (-e "/tmp/etherToIP") { 
  85.     # Running IRIX 6.5 - clean up text file
  86.     system("/sbin/rm", "-f", "/tmp/etherToIP");
  87. }
  88.  
  89. print "</table></center>\n";
  90.